import tpl from './index.tpl';
import './index.scss';

import { tplReplace } from '../../../utils/tools'

export default () => {
    return {
        name: 'headerNav',
        tpl(fieldData) {
            let list = '';

            fieldData.forEach(item => {
                list += tplReplace(tpl, {
                    field: item.field,
                    fieldName: item.field_name
                })

                // list += tpl().replace(/{{(.*?)}}/g, (node, key) => {
                //     return {
                //         field: item.field,
                //         fieldName: item.field_name
                //     }[key]
                // })
            });

            return `<ul class="nav-list clearfix">${list}</ul>`
        }
    }
}